function notifyMessage (message, options, callback) {
    // Notification 是否能用 && 是否同意接受通知
    if (Notification && Notification.permission === 'granted') {
        // 发送通知
        var notification = new Notification(message, options)
        callback(null, notification)
    } else if (Notification.requestPermission) {
        // 向用户获取权限
        Notification.requestPermission(function(status) {
            console.log('status', status);
            
            if (Notification.permission !== status) {
                Notification.permission = status
            }
            if (status === 'granted') {
                var notification = new Notification(message, options)
                callback(null, notification)
            } else {
                callback(new Error('user denied'))
            }
        })
    } else {
        callback(new Error('doesn\'t support Notification API'))
    }
}
notifyMessage('Hi', {}, function (error, notification) {
    if (error) {
        return console.error(error);
    }
    console.log(notification);
})

/*************************************************************************/

// Notification.requestPermission 已 promise 化
function notifyMessage (message, options, callback) {
    // Notification 是否能用 && 是否同意接受通知
    if (Notification && Notification.permission === 'granted') {
        // 发送通知
        var notification = new Notification(message, options)
        callback(null, notification)
    } else if (Notification.requestPermission) {
        // 向用户获取权限
        Notification.requestPermission().then(function (status) {
            console.log('status', status);
            if (status === 'granted') {
                callback(null, notification)
            } else {
                callback(new Error('user denied'))
            }
        })
    } else {
        callback(new Error('doesn\'t support Notification API'))
    }
}